#include "personwidget.h"
#include "ui_personwidget.h"
#include "mainwidget.h"
#include "ui_mainwidget.h"
#include <QPushButton>

static MainWidget * ptrParent;

personWidget::personWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::personWidget)
{
    ui->setupUi(this);
    ptrParent = (MainWidget *)parentWidget();

    connect(ui->btnInfo, &QPushButton::clicked, this, &personWidget::btnInfo_clicked);
    connect(ui->btnWare, &QPushButton::clicked, this, &personWidget::btnWare_clicked);
    connect(ui->btnOut, &QPushButton::clicked, this, &personWidget::btnOut_clicked);
}

personWidget::~personWidget()
{
    delete ui;
}

void personWidget::leaveEvent(QEvent *event)
{
    Q_UNUSED(event);
    this->close();
}

void personWidget::btnInfo_clicked()
{
    this->close();
    ptrParent->ui->stackedWidget->setCurrentIndex(4);
    QString basicStyleSheet = "QPushButton{font-size:22px;font-family:'黑体';background:transparent;color:rgb(240,240,240);border-radius:10px}"
                              "QPushButton:hover{background-color:rgb(87, 29, 203)}"
                              "QPushButton:pressed{background-color:rgb(69, 23, 162)}";
    ptrParent->ui->btnPage1->setStyleSheet(basicStyleSheet);
    ptrParent->ui->btnPage2->setStyleSheet(basicStyleSheet);
    ptrParent->ui->btnPage3->setStyleSheet(basicStyleSheet);
    ptrParent->ui->btnPage4->setStyleSheet(basicStyleSheet);
}

void personWidget::btnWare_clicked()
{
    this->close();

    ptrParent->remakePersonalSpace();
}

void personWidget::btnOut_clicked()
{
    this->close();
    ptrParent->close();
    emit backLogin();
}
